package stackOverflow;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;


/**
 * @author Boris Cherkasky
 *
 */
public class AnswerObject extends CodeObject{
    private boolean		isAccepted;	//if answer - flag that indicates if it was accepted
    
    public AnswerObject(ArrayList<String> code, int date, boolean isAccepted,
	    int userRep, int upVoteCount, int id) {
	super(code, date, userRep, upVoteCount, id);
	this.isAccepted = isAccepted;
    }

    public AnswerObject(String body, int date, boolean isAccepted,
	    int userRep, int upVoteCount, int id) {
	super(body, date, userRep, upVoteCount, id);
	this.isAccepted = isAccepted;
    }

    public AnswerObject() {
	super();
	isAccepted = false;
    }

    public boolean isAccepted() {
        return isAccepted;
    }

    public void setAccepted(boolean isAccepted) {
        this.isAccepted = isAccepted;
    }
    
    public void showMeta(){
	super.showMeta();
	System.out.println("/*\t|-------------------");
	System.out.println("\t|Is Accepted  	: \t" + isAccepted);
	System.out.println("\t|-------------------*/");
    }
    
    public void showMeta (FileWriter writer) throws IOException{
	super.showMeta(writer);
	if (writer == null){
	    System.out.println("/*\t|-------------------");
	    System.out.println("\t|Is Accepted  	: \t" + isAccepted);
	    System.out.println("\t|-------------------*/");
	    return;
	} else {
	    writer.write("/*\t|-------------------\n");
	    writer.write("\t|Is Accepted  	: \t" + isAccepted + "\n");
	    writer.write("\t|-------------------*/\n");
	}
    }
}
